package cn.itcast.wushangxiantu.BaseAdapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import cn.itcast.wushangxiantu.R;

public class ChouJiangGiveViewAdapter extends BaseAdapter {
    private Context context;
    public static String[] NongYuanWpName={"杂草","金丝银线","金丝楠木","蚕丝","石头",
            "天蚕丝","杂草","紫檀木","木头","水晶",
            "橡胶","龟壳","石魂","铁","黄金",
            "红木","石头","布匹","咸鱼","黑曜石",
            "咸鱼","龙珠","海怪牙齿","珊瑚","木头"};
    public static String[] SenLinWpName={"魔核","二阶魔核","石魂","四阶魔核","魔核",
            "魔核","五阶魔核","石魂*10","七阶魔核","魔核",
            "魔核","八阶魔核","九阶魔核","六阶魔核","魔核",
            "魔核","三阶魔核","十阶魔核","一阶魔核","魔核"};
    public static String[] JinBiName={"10金币","10金币","10金币","10金币","10金币",
            "20金币","20金币","50金币","20金币","20金币",
            "30金币","100金币","1000金币","100金币","30金币",
            "20金币","20金币","50金币","20金币","20金币",
            "10金币","10金币","10金币","10金币","10金币"};
    public static String[]Name;
    static int  num=1;
    public ChouJiangGiveViewAdapter(Context context) {
        this.context = context;
        Name=JinBiName;
    }

    public void setNum(int num) {
        if (num==0){

            Name=SenLinWpName;
        }else if (num==1){
            Name=JinBiName;
        }else if (num==2){
            Name=NongYuanWpName;
        }
        notifyDataSetChanged();
        this.num=num;
    }

    public int getNum() {
        return num;
    }

    @Override
    public int getCount() {
        return Name.length;
    }

    @Override
    public Object getItem(int i) {
        return Name[i];
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @SuppressLint("ResourceAsColor")
    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = View.inflate(context, R.layout.griveview_bag, null);
       ViewHolder viewHolder=new ViewHolder(view);
       viewHolder.tvName.setText(Name[i]);
       switch (num){
           case 2:
                if (i==0||i==4||i==24||i==20||i==6||i==8||i==16||i==18){
                    viewHolder.tvName.setTextColor(ContextCompat.getColor(context,R.color.lingshi1));
                }else if (i==12){
                    viewHolder.tvName.setTextColor(ContextCompat.getColor(context,R.color.lingshi6));
                }else{
                    viewHolder.tvName.setTextColor(ContextCompat.getColor(context,R.color.lingshi4));
                }
               break;
           case 1:
               if (i<=4||i>=20){
                   viewHolder.tvName.setTextColor(ContextCompat.getColor(context,R.color.lingshi1));
               }else if (i==12){
                   viewHolder.tvName.setTextColor(ContextCompat.getColor(context,R.color.lingshi6));
               }else{
                   viewHolder.tvName.setTextColor(ContextCompat.getColor(context,R.color.lingshi4));
               }
               break;
           case 0:
               if ((i+1)%5==0||(i+1)%5==1){
                   viewHolder.tvName.setTextColor(ContextCompat.getColor(context,R.color.lingshi1));
               }else if (i==2){
                   viewHolder.tvName.setTextColor(ContextCompat.getColor(context,R.color.lingshi6));
               }else if (i==7){
                   viewHolder.tvName.setTextColor(ContextCompat.getColor(context,R.color.lingshi9));
               }else {
                   viewHolder.tvName.setTextColor(ContextCompat.getColor(context,R.color.lingshi4));

               }
               break;
       }
       viewHolder.tvNumber.setVisibility(View.INVISIBLE);
        return view;
    }

    class ViewHolder {
        public View rootView;
        public TextView tvName;
        public TextView tvNumber;
        public ViewHolder(View rootView) {
            this.rootView = rootView;
            this.tvName = (TextView) rootView.findViewById(R.id.tvName);
            this.tvNumber = (TextView) rootView.findViewById(R.id.tvNumber);
        }

    }
}
